<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
<script>
	function Vue(options){
		var {data, methods, computed} = options
		for (var key in data) {
			this[key] = data[key]
		}
		for (var key in methods) {
			this[key] = methods[key]
		}
		for (var key in computed) {
			Object.defineProperty(this, key, {
				get:computed[key]
			})
		}
	}
	var app = new Vue({
		data:{
			message:'hello',
			foo:'bar',
			fruits:['苹果','香蕉']
		},
		computed:{
			// vue内部帮你把这个方法变为leftCount 的get 访问器了
			leftCount:function(){
				console.log(123)
			}
		},
		methods:{
			addTodo(){
				console.log(this.message)
				this.haha()
			},
			haha(){
				console.log(this.foo)
				console.log('hahaha')
				this.fruits.forEach(function(){
					console.log(this)
				})
			}
		}
	})
</script>
</body>
</html>